// components/test/listcomment.js
Component({

  /**
   * 组件的属性列表
   */
  options:{
      styleIsolation:'isolated'

  },
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    products:[
        {id:1,title:'无糖燕麦片',price:39.9,thumb:'https://ts1.tc.mm.bing.net/th/id/OIP-C.Fe3G12jGnzA5-E9ozhJ5HAHaLH?rs=1&pid=ImgDetMain&o=7&rm=3=无糖燕麦片'},
    {id:2,title:'精品橙子',price:19.9,thumb:'https://ts2.tc.mm.bing.net/th/id/OIP-C.vjAKu3GTPiKzjrI3NLjNkQHaHa?rs=1&pid=ImgDetMain&o=7&rm=3=橙子'}

    ],
    cmtVisible:false,
    cmtText:'',
    cmtPid:null
    

  },
  
  

  /**
   * 组件的方法列表
   */
  methods: {
   
  onShow(){
    // 从缓存读取最新数据
    const products = wx.getStorageSync('products') || this.initProducts()
    this.setData({products})
  },

  initProducts(){
    const list = [
        {id:1,title:'无糖燕麦片',price:39.9,thumb:'https://ts1.tc.mm.bing.net/th/id/OIP-C.Fe3G12jGnzA5-E9ozhJ5HAHaLH?rs=1&pid=ImgDetMain&o=7&rm=3=无糖燕麦片'},
        {id:2,title:'精品橙子',price:19.9,thumb:'https://ts2.tc.mm.bing.net/th/id/OIP-C.vjAKu3GTPiKzjrI3NLjNkQHaHa?rs=1&pid=ImgDetMain&o=7&rm=3=橙子'}
    ]
    wx.setStorageSync('products',list)
    return list
  },
  toComment(e){
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/goodcomment/goodcomment?id=${id}`,
    })
},
   
      

  }
})